package ch12_容器框架与泛型.案例实践_产品排序;

import ch12_容器框架与泛型.Product;

import java.util.Comparator;

public class ProductComparator implements Comparator<Object>{
	//自定义排序
	@Override
	public int compare(Object o1, Object o2) {
		Product p1 = (Product) o1;		//造型为产品对象
		Product p2 = (Product) o2;
		//return值作为排序依据
		return p1.getInventory() - p2.getInventory();	//以库存升序排列
	}



}
